package com.keystudio;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

import com.keystudio.util.ContantsUtil;

public class ShareInfoActivity extends Activity {

	private ArrayAdapter<String> adapterType;
	private Spinner mySpinner;
	private Button btnNext;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shareinfo);
		mySpinner = (Spinner) findViewById(R.id.spinner_type);
		adapterType = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, ContantsUtil.getType());
		adapterType
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mySpinner.setAdapter(adapterType);

		btnNext = (Button) findViewById(R.id.btnNext);
		btnNext.setOnClickListener(new Button.OnClickListener() {
			@Override
			public void onClick(View v) {
				switch ((int) mySpinner.getSelectedItemId()) {
				case 0:
					Intent shareSchoolIntent = new Intent();
					shareSchoolIntent.setClass(ShareInfoActivity.this,
							ShareSchoolActivity.class);
					startActivity(shareSchoolIntent);
					break;
				case 2:
					Intent shareClassIntent = new Intent();
					shareClassIntent.setClass(ShareInfoActivity.this,
							ShareClassActivity.class);
					startActivity(shareClassIntent);
					break;
				default:
					Intent shareElseIntent = new Intent();
					Bundle bundle = new Bundle();
					String type = mySpinner.getSelectedItem().toString();
					type=ContantsUtil.getTypeNameByC(type);
					bundle.putString("type", type);
					shareElseIntent.putExtras(bundle);
					shareElseIntent.setClass(ShareInfoActivity.this,
							ShareElseActivity.class);
					startActivity(shareElseIntent);
					break;
				}
			}
		});
	}
}
